package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
	"hcy-api/lib/middleware"
	"lms/global"
)

func main() {
	defer logrus.Panic("系统崩溃")
	//初始化日志
	global.InitLmsConfig("config_lms")
	global.InitLogger()
	// 初始化数据库
	global.InitDB()
	// 初始化http服务
	app := gin.New()
	static := app.Group("/api/lms/static")
	static.Static("/courseware", "./courseware")
	r := app.Group("/api/lms")
	r.Use(middleware.GinAuthorizationMiddleAware())
	RegisterRouter(r)
	ws := app.Group("/api/lms")
	PublicRouter(ws)
	err := app.Run(fmt.Sprintf(":%d", global.LmsConf.ApiPort))
	if err != nil {
		logrus.Error("http服务启动失败：", err)
	}
}
